﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;

public partial class Home : System.Web.UI.Page
{
    CustormerMethord Cm = new CustormerMethord();
    protected void Page_Load(object sender, EventArgs e)
    {
        if(!IsPostBack)
        {
            LoadTopJewelry();
            LoadTopDiamond();
            LoadTopStores();
            LoadTopGold();
        }
    }

    private void LoadTopGold()
    {
        DataTable dt = new DataTable();
        try
        {
            dt = Cm.Gold();
            string url1 = dt.Rows[0][1].ToString();
            string url2 = dt.Rows[1][1].ToString();
            string url3 = dt.Rows[2][1].ToString();



            ibnGold1.ImageUrl = url1;
            ibnGold2.ImageUrl = url2;
            ibnGold3.ImageUrl = url3;
        }
        catch (Exception ex)
        {
            Response.Redirect("Errors.aspx");
        }
    }

    private void LoadTopStores()
    {
        DataTable dt = new DataTable();
        try
        {
            dt = Cm.Stores();
            string url1 = dt.Rows[0][1].ToString();
            string url2 = dt.Rows[1][1].ToString();
            string url3 = dt.Rows[2][1].ToString();



            ibnStores1.ImageUrl = url1;
            ibnStores2.ImageUrl = url2;
            ibnStores3.ImageUrl = url3;
        }
        catch (Exception ex)
        {
            Response.Redirect("Errors.aspx");
        }
    }

    private void LoadTopDiamond()
    {
        DataTable dt = new DataTable();
        try
        {
            dt = Cm.Diamond();
            string url1 = dt.Rows[0][1].ToString();
            string url2 = dt.Rows[1][1].ToString();
            string url3 = dt.Rows[2][1].ToString();

           

            ibnDiamon1.ImageUrl = url1;
            ibnDiamon2.ImageUrl = url2;
            ibnDiamon3.ImageUrl = url3;
        }
        catch (Exception ex)
        {
            Response.Redirect("Errors.aspx");
        }
    }

    private void LoadTopJewelry()
    {
        DataTable dt = new DataTable();
        try
        {
            dt = Cm.Jewellry();
            string url1 = dt.Rows[0][1].ToString();
            string url2 = dt.Rows[1][1].ToString();
            string url3 = dt.Rows[2][1].ToString();
             
           

            ibnJewelry1.ImageUrl = url1;
            ibnJewelry2.ImageUrl = url2;
            ibnJewelry3.ImageUrl = url3;
        }
        catch (Exception ex) 
        {
            Response.Redirect("Errors.aspx");
        }
    }
    
    protected void ibnJewelry1_Click(object sender, ImageClickEventArgs e)
    {
        DataTable dt = Cm.Jewellry();
       string id1 = dt.Rows[0][0].ToString();
        Response.Redirect("ProductDetails.aspx?ProID="+ id1.ToString()+"");
    }
    protected void ibnJewelry2_Click(object sender, ImageClickEventArgs e)
    {
        DataTable dt = Cm.Jewellry();
        string id2 = dt.Rows[1][0].ToString();
        Response.Redirect("ProductDetails.aspx?ProID=" + id2.ToString() + "");
    }
    protected void ibnJewelry3_Click(object sender, ImageClickEventArgs e)
    {
        DataTable dt = Cm.Jewellry();
        string id3 = dt.Rows[2][0].ToString();
        Response.Redirect("ProductDetails.aspx?ProID=" + id3.ToString() + "");
    }
    protected void ibnDiamon1_Click(object sender, ImageClickEventArgs e)
    {
        DataTable dt = Cm.Diamond();
        string id1 = dt.Rows[0][0].ToString();
        Response.Redirect("ProductDetails.aspx?ProID=" + id1.ToString() + "");
    }
    protected void ibnDiamon2_Click(object sender, ImageClickEventArgs e)
    {
        DataTable dt = Cm.Diamond();
        string id1 = dt.Rows[1][0].ToString();
        Response.Redirect("ProductDetails.aspx?ProID=" + id1.ToString() + "");
    }
    protected void ibnDiamon3_Click(object sender, ImageClickEventArgs e)
    {
        DataTable dt = Cm.Diamond();
        string id1 = dt.Rows[2][0].ToString();
        Response.Redirect("ProductDetails.aspx?ProID=" + id1.ToString() + "");
    }
    protected void ibnStores1_Click(object sender, ImageClickEventArgs e)
    {
        DataTable dt = Cm.Stores();
        string id1 = dt.Rows[0][0].ToString();
        Response.Redirect("ProductDetails.aspx?ProID=" + id1.ToString() + "");
    }
    protected void ibnStores2_Click(object sender, ImageClickEventArgs e)
    {
        DataTable dt = Cm.Stores();
        string id1 = dt.Rows[1][0].ToString();
        Response.Redirect("ProductDetails.aspx?ProID=" + id1.ToString() + "");
    }
    protected void ibnStores3_Click(object sender, ImageClickEventArgs e)
    {
        DataTable dt = Cm.Stores();
        string id1 = dt.Rows[2][0].ToString();
        Response.Redirect("ProductDetails.aspx?ProID=" + id1.ToString() + "");
    }
    protected void ibnGold1_Click(object sender, ImageClickEventArgs e)
    {
        DataTable dt = Cm.Gold();
        string id1 = dt.Rows[0][0].ToString();
        Response.Redirect("ProductDetails.aspx?ProID=" + id1.ToString() + "");
    }
    protected void ibnGold2_Click(object sender, ImageClickEventArgs e)
    {
        DataTable dt = Cm.Gold();
        string id1 = dt.Rows[1][0].ToString();
        Response.Redirect("ProductDetails.aspx?ProID=" + id1.ToString() + "");
    }
    protected void ibnGold3_Click(object sender, ImageClickEventArgs e)
    {
        DataTable dt = Cm.Gold();
        string id1 = dt.Rows[2][0].ToString();
        Response.Redirect("ProductDetails.aspx?ProID=" + id1.ToString() + "");
    }
}